package demo;

/**
 * @Author 12629
 * @Description：
 */
class Student {
    private String name;
    private int age;
    private static String classRoom;
    public Student() {
        System.out.println("Student()");
    }
    //实例代码块

    /*{
        System.out.println("实例代码块执行了2....");
    }*/
/*
    {
        name = "feifei";
        System.out.println("实例代码块执行了1....");
    }
    //静态代码块 加载的时候
    static {
        System.out.println("静态代码块执行了2....");
    }

    static {
        classRoom = "115java";
        //name = "fafa";
        System.out.println("静态代码块执行了1....");
    }*/


    public Student(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("构造Student(String name, int age)方法执行了....");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public static String getClassRoom() {
        return classRoom;
    }

    public static void setClassRoom(String classRoom) {
        Student.classRoom = classRoom;
    }

    public void func() {
        int a = 10;
        {
            int b = 20;
            System.out.println(a+b);
        }
        //System.out.println(b);
    }

    public void show() {
        System.out.println("姓名："+name+" 年龄："+age);
    }

    /*public String toString() {
        return "姓名："+name+" 年龄："+age + " 上课教室："+classRoom;
    }*/

    @Override
    public String toString() {
        return "Student{" +
                "姓名='" + name + '\'' +
                ", 年龄=" + age +
                '}';
    }

}
public class TestDemo {
    public static void main2(String[] args) {
        System.out.println(Student.getClassRoom());
        System.out.println("====");
        System.out.println(Student.getClassRoom());
    }



    public static void main(String[] args) {

        Student student1 = new Student("zhangsan",10);
        //student1.show();

        System.out.println(student1);


        //System.out.println("=====");

        //Student student2 = new Student("zhangsan",10);

    }
}
